package com.lyfam.annotation.builder;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.vaadin.ui.Field;

public class FieldBuilderImpl implements FieldBuilder
{
    private Map<String, Field> fields = new HashMap<String, Field>();
    
    public Field createField(String fieldName, FieldCreator fieldCreator)
    {
        Field field = fieldCreator.getField();
        fields.put(fieldName, field);
        return field;
    }

    public Map<String, Field> getFields()
    {
        return Collections.unmodifiableMap(fields);
    }

    public Field getField(String fieldName)
    {
        return fields.get(fieldName);
    }

    public Field createField(String fieldName, Field field)
    {
        fields.put(fieldName, field);
        return field;
    }

}
